import { unix2Moment } from 'src/utils/common';
import Moment from 'moment';
export default class Base {
  public id = '';
  public createTime = 0;
  public get createTimeHuman(): string {
    return unix2Moment(this.createTime).fromNow();
  }
  public get createTimeLabel(): string {
    return unix2Moment(this.createTime).format('ll');
  }
  public get createTimeGroupName(): string {
    const createMoment = Moment(this.createTime);
    if (createMoment.isValid()) {
      const diffWeeks = Moment().diff(createMoment, 'weeks');
      const diffMonths = Moment().diff(createMoment, 'months');
      if (diffWeeks <= 1) {
        return 'week';
      } else if (diffMonths <= 1) {
        return 'month';
      } else {
        return 'earlier';
      }
    }
    return 'earlier';
  }
}
